/*
 * @Descripttion: 
 * @version: 
 * @Author: TT
 * @Date: 2023-03-20 22:29:09
 * @LastEditors: TT
 * @LastEditTime: 2023-03-20 22:29:09
 */

// 路由中间件（登录拦截）
import 'package:flutter/material.dart';
import 'package:hzy_common_module/hzy_common_module.dart';

class AuthMiddleware extends GetMiddleware {
  @override
  RouteSettings? redirect(String? route) {
    debugPrint('=======AuthMiddleware.redirect:$route');
    if (!userislogin()) {
      return const RouteSettings(name: '/loginOne/load');
    }
    return super.redirect(route);
  }
}

GetPage configAuthMilderPage({
  required String name,
  required GetPageBuilder page,
  bool isIntercept = true,
  Bindings? binding,
}) {
  return GetPage(
    name: name,
    page: page,
    middlewares: isIntercept ? [AuthMiddleware()] : null,
    binding: binding,
  );
}

/// 判断用户是否登录
bool userislogin() {
  String? token = "";
  //CurrentSputils.getUserinfo();
  dprint(token);
  bool islogin = true;
  if (token == "") {
    islogin = false;
  }
  return islogin;
}
